home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / pas2c.zip / PATCHTPC.PAS < prev    next >
Pascal/Delphi Source File  |  1993-01-04  |  6KB  |  166 lines

  1. {
  2.  
  3. Problem with Turbo Pascal V4.0 - Inter-Language Linking
  4.  
  5. Product Serial Number: A4B0071808
  6.  
  7. The compiler gives an error 51 "Invalid PUBLIC definition" when using OBJ
  8. files that have PUBLIC symbols that are not defined as "external" declarations
  9. in Pascal. This is in accordance with the manual, page 617.
  10.  
  11. I am attempting to use Turbo C (serial number: X1D0080047) subprograms with
  12. Turbo Pascal V4.0. Turbo C intrinsic functions have a '@' character appended
  13. to the name (eg. LDIV@). If the C code requires the use of such an intrinsic,
  14. it generates the appropriate call. I have extracted the intrinsic functions
  15. from the C run-time library, and have corrected the CODE and DATA segments to
  16. properly convert and load with Turbo Pascal. Unfortunately, the '@' sign is
  17. an illegal character in Turbo Pascal identifiers. Therefore, references to
  18. the Turbo C intrinsic functions cannot be satisfied, because the Turbo Pascal
  19. OBJ capability requires identification of ALL public symbols, and the intrinsic
  20. identifiers cannot be syntactically defined.
  21.  
  22. I believe that the requirement for all publics in OBJ files to be
  23. declared in the using Pascal program to be to restrictive. It is definitely
  24. putting a damper on our development efforts. The implication of this problem
  25. is that some C code, even if it does not use ANY of the documented C library
  26. functions cannot be made to work with Turbo Pascal. C code using long divide,
  27. long shifting, structure assignment and structure passing cannot be used with
  28. Turbo Pascal. I use structure passing in C programs extensively, and consider
  29. this a crucial feature.
  30.  
  31. Sincerely Yours,
  32.  
  33. Martin Weigel,
  34.  
  35. Chameleon Typeface Foundry Inc.
  36. Suite 2720,
  37. 145 King Street West,
  38. Toronto, Ontario,
  39. Canada    M5H 2J8
  40.  
  41. (416) 367-3668
  42.  
  43. #: 113334 S2/Turbo Pascal v.4
  44.     15-Dec-87  21:47:58
  45. Sb: #113316-Language Linking Problem
  46. Fm: Kim Kokkonen 72457,2131
  47. To: Martin Weigel 76237,733
  48.  
  49. Martin - I'm not so sure the patch will be easy, or even possible. '@' is now
  50. an operator in Turbo Pascal 4.0 (meaning "address of"), and without disabling
  51. that feature of the language, it will be really tricky to allow it in
  52. identifier names. And modifying the linker to not require a matchup between
  53. EXTRNs and Pascal identifiers would be even harder.
  54.  
  55. (speaking as a hacker)
  56.  
  57. -Kim
  58.  
  59.  
  60. #: 113407 S2/Turbo Pascal v.4
  61.     16-Dec-87  14:11:59
  62. Sb: #113316-Language Linking Problem
  63. Fm: John Sieraski (Borland) 76117,2022
  64. To: Martin Weigel 76237,733
  65.  
  66.   Martin, Like Kim has already mentioned, a correction to the inter-language
  67. linking problems that you have encountered would require a lot more than a
  68. patch. I have submitted a suggestion to our development folks that they
  69. consider making inter-language linking with Borland languages easier. I know
  70. that inter-language linking is an important issue and Borland is definitely
  71. working on a solution for this. For now, there isn't any solution available,
  72. but in the future I'm sure there will be.
  73.   --John
  74.  
  75.  
  76. #: 113409 S2/Turbo Pascal v.4
  77.     16-Dec-87  14:15:00
  78. Sb: #PUBLIC Linkage
  79. Fm: Kim Kokkonen 72457,2131
  80. To: Martin Weigel 76237,733
  81.  
  82. Well Martin, you got my curiosity up, and I think I've got a patch that will do
  83. the trick for you. I've tested this with some of our assembly language, adding
  84. extra PUBLICs and naming things ending with '@', but I haven't tested it with
  85. actual C code. In my tests, I haven't found any problems. The only limitation
  86. is that the patch needs to use a little extra code space, so some of the other
  87. PUBLIC errors won't give as descriptive an error message because I had to
  88. overwrite that code.
  89.  
  90. The patch works only on TPC.EXE. Make a backup copy of the compiler first,
  91. because the patch program will overwrite TPC.EXE. It will make the copyright
  92. version number appear as "4.pi" so you'll know you're using the patched
  93. version. I'd be curious to hear if it works for you.
  94.  
  95. See the following message for the patching program.
  96.  
  97. -Kim
  98.  
  99.  
  100. #: 113421 S2/Turbo Pascal v.4
  101.     16-Dec-87  15:05:49
  102. Sb: #113409-#PUBLIC Linkage
  103. Fm: John Sieraski (Borland) 76117,2022
  104. To: Kim Kokkonen 72457,2131 (X)
  105.  
  106.   Martin, I guess that Kim has proved that maybe a patch _is_ all that's
  107. required to solve the inter-language problems you were having. I'll be lurking
  108. to see if your problems are cured with the patch. Where there's a will there's
  109. a way. I'm gonna try the patch out pronto. Thanks Kim, you and Brian never
  110. cease to impress me.
  111.   --John
  112.  
  113.  
  114. #: 113461 S2/Turbo Pascal v.4
  115.     16-Dec-87  21:28:21
  116. Sb: #113421-PUBLIC Linkage
  117. Fm: Kim Kokkonen 72457,2131
  118. To: John Sieraski (Borland) 76117,2022 (X)
  119.  
  120. You shouldn't thank me until we know whether it really works for his "C"
  121. problem. I'm afraid that there may be some hidden effect that hasn't shown up
  122. in the limited testing I did. We'll see...
  123.  
  124. -Kim
  125.  
  126.  
  127. Kim: Thanks for the patch. I missed the message about the patch the first
  128. time through (my option mask settings were wrong!). I will try it out
  129. right now!
  130. Many Thanks
  131. Martin.
  132.  
  133. }
  134.  
  135. program PatchTPC;
  136. var f : file of Byte;
  137.  
  138.   procedure Patch(loc : LongInt; o, n : Byte);
  139.   var b : Byte;
  140.   begin
  141.     Seek(f, loc); Read(f, b);
  142.     if b <> o then begin
  143.       WriteLn('Data should be ', o, ' but is ', b); Halt(1);
  144.     end;
  145.     Seek(f, loc); Write(f, n);
  146.   end;
  147.  
  148. begin
  149.   Assign(f, 'TPC.EXE'); Reset(f);
  150.   if FileSize(f) <> 41790 then begin
  151.     WriteLn('Unknown version of TPC.EXE'); Halt(1);
  152.   end;
  153.   Patch($7AE3,$2F,$29);
  154.   Patch($7AEA,$28,$22);
  155.   Patch($7B13,$B8,$58);
  156.   Patch($7B14,$33,$EB);
  157.   Patch($7B15,$00,$ED);
  158.   Patch($9068,$30,$E3);
  159.   Close(f);
  160. end.
  161.  
  162.  
  163.  
  164.  
  165.  
  166.